package com.tyk.bookstore.back.product.model.vo;

import com.tyk.bookstore.back.common.core.model.page.PageVo;
import com.tyk.bookstore.back.common.core.util.FileUtil;
import com.tyk.bookstore.back.product.model.enume.BookState;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * @author tyk
 * @description 书籍
 */
@Data
@Schema(name = "BookPageVo", description = "书籍")
public class BookPageVo extends PageVo<BookPageVo.Book> {
    @Data
    @Schema(name = "Book", description = "书籍")
    public static class Book implements Serializable {

        @Serial
        private static final long serialVersionUID = 1L;

        @Schema(description = "ID")
        private Long id;

        @Schema(description = "书籍编号")
        private String bookNo;

        @Schema(description = "书名")
        private String name;

        @Schema(description = "价格")
        private BigDecimal price;

        @Schema(description = "封面路径")
        private String cover;

        @Schema(description = "作者ID")
        private Long authorId;

        @Schema(description = "出版社ID")
        private Long publisherId;

        @Schema(description = "ISBN")
        private String isbn;

        @Schema(description = "低级分类ID")
        private Long clazzId;

        @Schema(description = "分类全称")
        private String clazzFullName;

        @Schema(description = "状态[0下架，1上架]")
        private BookState state;

        public Book setCover(String cover) {
            this.cover = FileUtil.fullFilePath(cover);
            return this;
        }
    }
}
